<%
 if(task_c.done==1); donestr = "done"; else; donestr=''; end
 if(task_c.star==1); starstr = "on"; else; starstr='off'; end
-%>

<% if(task_c.tasks.size > 0) -%>
  <% if(not expand) -%>
  <%= link_to_remote(image_tag('expand.gif'), :url => {:action=>:expand_task,:id=>task_c.id}, :update=>'item_'+task_c.id.to_s) %>
  <% else -%>
  <%= image_tag('collapse.gif') %>
  <% end -%>
<% else -%>
<div style="margin-left:16px;display:inline"></div>
<% end -%>

<a href="#" onclick="star_it(<%=task_c.id%>);return false;"><img src="/images/star_<%=starstr%>_2.gif" id="st<%=task_c.id%>" title="reminder"></a>
<%= render(:partial => 'priority', :locals => {:p=>task_c.priority}) %>
<% if session[:selected_project] == 0 %>
<b><%=task_c.project.name %></b>
<% end %>
<%=task_c.title %>
(<%=task_c.user.name %>)
<%= render(:partial => 'deadline', :locals => {:task=>task_c}) -%>
<% if(task_c.notes_count > 0) %>(<a href="#" onclick="notes(<%=task_c.id%>);return false;"><%= task_c.notes_count -%> notes</a>)<% end %>
<div class="tags"><%=task_c.tags.map{|t| t.name }.join(", ")%></div>
<div class="done_on"><% if task_c.done_on %>done <%= time_ago_in_words(task_c.done_on) %> ago<% end %></div>
<a href="#" title="edit" onclick="edit(<%=task_c.id%>);return false;"><img id="e<%=task_c.id%>" src="/images/edit.gif"></a>

<% if(task_c.tasks.size > 0) -%>
<a href="#" title="display only subtasks" onclick="disp_sub(<%=task_c.id%>);return false;"><img src="/images/disp_sub.gif"></a>
<% end -%>

<a href="#" title="add a sub task" onclick="add_sub(<%=task_c.id%>);return false;"><img id="a<%=task_c.id%>" src="/images/add.png"></a>


<ul id="sub<%=task_c.id%>">
<% if(expand) -%>
<%= render(:partial=>'task', :collection=>tasks.select {|t| t.task_id==task_c.id and t.done==0}.sort_by{|t| t.order}, :locals=>{:tasks=>tasks, :expand=>nil}) %>
<% end -%>
</ul>

